package com.flower.subject.domain.handler.subject;

import com.flower.subject.domain.convent.BriefSubjectConverter;
import com.flower.subject.domain.entity.SubjectInfoBO;
import com.flower.subject.domain.entity.SubjectOptionBO;
import com.flower.subject.enums.SubjectInfoTypeEnum;
import com.flower.subject.infra.basic.entity.SubjectBrief;
import com.flower.subject.infra.basic.entity.SubjectRadio;
import com.flower.subject.infra.basic.service.SubjectBriefService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;

import static com.flower.subject.domain.convent.BriefSubjectConverter.INSTANT;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-08 14:48
 * 判断题目策略类
 */
@Component
public class BriefTypeHandler implements SubjectTypeHandler{


    @Resource
    private SubjectBriefService subjectBriefService;
    @Override
    public SubjectInfoTypeEnum getSubjectType() {
        return SubjectInfoTypeEnum.BRIEF;
    }

    @Override
    public void add(SubjectInfoBO subjectInfoBO) {
        SubjectBrief subjectBrief = INSTANT.convertBoToEntity(subjectInfoBO);
        subjectBrief.setSubjectId(subjectInfoBO.getId().intValue());
        subjectBriefService.insert(subjectBrief);



    }

    @Override
    public SubjectOptionBO query(Integer subjectId) {
        SubjectBrief subjectBrief = new SubjectBrief();
        subjectBrief.setSubjectId(subjectId);
        subjectBrief = subjectBriefService.queryByCondition(subjectBrief);
        SubjectOptionBO bo = new SubjectOptionBO();
        bo.setSubjectAnswer(subjectBrief.getSubjectAnswer() + "");
        return bo;
    }
}
